
// **************************
// AJAX 部分
// **************************
function loadText(){

	xmlHttp = new XMLHttpRequest();
	xmlHttp.onreadystatechange = checkStatus;
	xmlHttp.open("GET","../act1000/act1002",true);

	xmlHttp.send(null);

}

var newDiv="";
var cnt=0;
function checkStatus(){

	if (xmlHttp.readyState == 4 && xmlHttp.status == 200){
		var xml = xmlHttp.responseXML;
		var rootNodes = xml.getElementsByTagName("list");
		var rootNode = rootNodes[0];
		var json = JSONConvert(rootNode);
		if (json==null) {
		} else {


			var arr = json.detail.split(",");
			var arrId = json.detailId.split("*");
			var arrAlarmNaiyo = json.detailAlarm.split("*");

			//alert(json.detail);

			//alert(json.detailId);

			//タイトルの側に表示する
			document.getElementById("ajaxId").innerHTML = "<img border='0' src='../../common/img/alert3.gif' width=35px' height='35px' style='vertical-align:top;'>"+json.item + cnt;

			var html ="";

			//設備情報リスト
			for(var k=1;k<arr.length;k++){

				html+= "<tr><td id='"+arrId[k]+"' ontouchstart='scroll1.setting(this);'>" + arr[k]+ "<br>"+arrAlarmNaiyo[k]+"</td></tr>"
			}

			document.getElementById("ajaxId2").innerHTML = html;
			//Ulタグを作成
			//newDiv += "	<ul>";
			//newDiv += "	  <li>"+json.detail + cnt +"</li>";
			//newDiv += "	</ul>";

			//document.getElementById("newId").innerHTML = newDiv;

			 cnt++;
		}
	}
}

function JSONConvert(node){
	var type = node.nodeType;
	if ( isTextNode(node) ){
		var text = getTextValue(node);
		return text;
	}
	if ( type==1 ){
		var json = {};
		var nodeName = node.nodeName;
		var childs = node.childNodes;

		for (var i = 0; i<childs.length; i++){
			var child = childs[i];
			var obj = json[child.nodeName];

			if ( child.nodeType == 1 ){
				if ( obj ){
					var array = null;
					if ( !isArray(obj) ){
						array=[];
						array[array.length]=obj;
					}else{
						array=json[child.nodeName];
					}
					array[array.length]=JSONConvert(child);
					json[child.nodeName]=array;
				}else{
					json[child.nodeName]=JSONConvert(child);
				}
			}
		}
		return json;
	}
}

function isTextNode(node){
	if ( node.hasChildNodes() ){
		var childs = node.childNodes;
		for (var i = 0; i<childs.length; i++){
			var child = childs[i];
			if ( child.nodeType != 3 ) return false;
		}
	}
	return true;
}


function getTextValue(node){
	if ( node.hasChildNodes() ){
		var childs = node.childNodes;
		var child = childs[0];
		if ( child.nodeType == 3 ){
			return child.nodeValue;
		}
	}
	return null;
}

//-----------------------------------------------------------------------
//押下すると現在時間を表示
function nowTime(obj){

 	var timeObj = document.getElementById(obj);

	var now = new Date();

	var hour = now.getHours(); // 時
	var min = now.getMinutes(); // 分
	var sec = now.getSeconds(); // 秒


	if(hour < 10) { hour = "0" + hour; }
	if(min < 10) { min = "0" + min; }
	if(sec < 10) { sec = "0" + sec; }


    document.getElementById(obj).value = hour + ':' + min;

}


//ラインコードが選択されているかどうかをチェック
function lineChk(obj){

	var obj;

	var lineCd = document.getElementById("drpLineNm");


	if(lineCd.value == ""){

		   //OP情報のHTML作成
		var html = "";
	    var htmlBtn = "";

		html += "<table width='100%'>\n";

		html += "<tr>\n";
		html += "	<td style='font-size:20px; color:blue;'>\n";

		if(obj == "drpEquipmentCd"){
			html += "			<br>「ライン名」を選択後、「設備機番」を<br>　選択して下さい。";
		}else if(obj == "drpProcessNo"){
			html += "			<br>「ライン名」を選択後、「工程NO」を<br>　選択して下さい。";
		}

		html += "	</td>\n";
		html += "</tr>\n";

		html += "</table>\n";

		htmlBtn ="";

		htmlBtn += "<table'>\n";
		htmlBtn += "<tr>\n";
		htmlBtn += "	<td  >　　　　　　";
		htmlBtn += "		<input type='button' id='opBtn' class='opBtn' onclick = 'back();'  value='確 認'>";
		htmlBtn += "	</td>";

		htmlBtn += "</tr>\n";
		htmlBtn += "</table>\n";


		document.getElementById("opBoard").innerHTML = html;
		document.getElementById("opBoardBtn").innerHTML = htmlBtn;

		document.getElementById("opBoard").style.display = "inline";
		document.getElementById("opBoardButtom").style.display = "inline";
		document.getElementById("opBoardBtn").style.display = "inline";
		document.getElementById("opBoardTop").style.display = "inline";

		//パップアップ以外は非活性
		document.getElementById("allbackgr").style.display = "inline";

	}
}



//作業内容がが選択されているかどうかをチェック
function lineChk2(obj){

	var workNm1 = document.getElementById("drpWorkNm1");
	var workNm2 = document.getElementById("drpWorkNm2");

	if(workNm1.value == ""){

		   //OP情報のHTML作成
		var html = "";
	    var htmlBtn = "";

		html += "<table width='100%'>\n";

		html += "<tr>\n";
		html += "	<td style='font-size:20px; color:blue;'>\n";
		html += "			<br>「作業内容①」を選択後、「作業内容②」　を選択して下さい。";
		html += "	</td>\n";
		html += "</tr>\n";

		html += "</table>\n";

		htmlBtn ="";

		htmlBtn += "<table'>\n";
		htmlBtn += "<tr>\n";
		htmlBtn += "	<td  >　　　　　　";
		htmlBtn += "		<input type='button' id='opBtn' class='opBtn' onclick = 'back();'  value='確 認'>";
		htmlBtn += "	</td>";

		htmlBtn += "</tr>\n";
		htmlBtn += "</table>\n";


		document.getElementById("opBoard").innerHTML = html;
		document.getElementById("opBoardBtn").innerHTML = htmlBtn;

		document.getElementById("opBoard").style.display = "inline";
		document.getElementById("opBoardButtom").style.display = "inline";
		document.getElementById("opBoardBtn").style.display = "inline";
		document.getElementById("opBoardTop").style.display = "inline";

		//パップアップ以外は非活性
		document.getElementById("allbackgr").style.display = "inline";

	}else if(workNm2.options[0] == undefined){

		//OP情報のHTML作成
		var html = "";
	    var htmlBtn = "";

		html += "<table width='100%'>\n";

		html += "<tr>\n";
		html += "	<td style='font-size:20px; color:blue;'>\n";
		html += "			<br> 　選択できる項目がありません。";
		html += "	</td>\n";
		html += "</tr>\n";

		html += "</table>\n";

		htmlBtn ="";

		htmlBtn += "<table'>\n";
		htmlBtn += "<tr>\n";
		htmlBtn += "	<td  >　　　　　　";
		htmlBtn += "		<input type='button' id='opBtn' class='opBtn' onclick = 'back();'  value='確 認'>";
		htmlBtn += "	</td>";

		htmlBtn += "</tr>\n";
		htmlBtn += "</table>\n";


		document.getElementById("opBoard").innerHTML = html;
		document.getElementById("opBoardBtn").innerHTML = htmlBtn;

		document.getElementById("opBoard").style.display = "inline";
		document.getElementById("opBoardButtom").style.display = "inline";
		document.getElementById("opBoardBtn").style.display = "inline";
		document.getElementById("opBoardTop").style.display = "inline";

		//パップアップ以外は非活性
		document.getElementById("allbackgr").style.display = "inline";

	}
}

//入力チェック
function inputChk(obj){


    //OP情報のHTML作成
	var html = "";
    var htmlBtn = "";

	html += "<table width='100%'>\n";

	html += "<tr>\n";
	html += "	<td style='font-size:20px; color:blue;'>\n";
	html += "			<br>　Please select "+obj+"";
	html += "	</td>\n";
	html += "</tr>\n";

	html += "</table>\n";

	htmlBtn ="";

	htmlBtn += "<table'>\n";
	htmlBtn += "<tr>\n";
	htmlBtn += "	<td  >　　　　　　";
	htmlBtn += "		<input type='button' id='opBtn' class='opBtn' onclick = 'back();'  value='確 認'>";
	htmlBtn += "	</td>";

	htmlBtn += "</tr>\n";
	htmlBtn += "</table>\n";


	document.getElementById("opBoard").innerHTML = html;
	document.getElementById("opBoardBtn").innerHTML = htmlBtn;

	document.getElementById("opBoard").style.display = "inline";
	document.getElementById("opBoardButtom").style.display = "inline";
	document.getElementById("opBoardBtn").style.display = "inline";
	document.getElementById("opBoardTop").style.display = "inline";

	//パップアップ以外は非活性
	document.getElementById("allbackgr").style.display = "inline";

}

//登録者権限の警告
function inputChk2(){
	//OP情報のHTML作成
	var html = "";
	var htmlBtn = "";

	html += "<table width='100%'>\n";

	html += "<tr>\n";
	html += "	<td style='font-size:20px; color:blue;'>\n";
	html += "			<br>　修正権限がありません。";
	html += "	</td>\n";
	html += "</tr>\n";

	html += "</table>\n";

	htmlBtn ="";

	htmlBtn += "<table'>\n";
	htmlBtn += "<tr>\n";
	htmlBtn += "	<td  >　　　　　　";
	htmlBtn += "		<input type='button' id='opBtn' class='opBtn' onclick = 'back();'  value='確 認'>";
	htmlBtn += "	</td>";

	htmlBtn += "</tr>\n";
	htmlBtn += "</table>\n";

	document.getElementById("opBoard").innerHTML = html;
	document.getElementById("opBoardBtn").innerHTML = htmlBtn;

	document.getElementById("opBoard").style.display = "inline";
	document.getElementById("opBoardButtom").style.display = "inline";
	document.getElementById("opBoardBtn").style.display = "inline";
	document.getElementById("opBoardTop").style.display = "inline";

	//パップアップ以外は非活性
	document.getElementById("allbackgr").style.display = "inline";
}

//修正・削除完了メッセージ
function registComplete(registType){
	//OP情報のHTML作成
	var html = "";
	var htmlBtn = "";
	var msg = "";
	if(registType == "update"){
		msg = "Edit";
	}else if(registType == "delete"){
		msg = "Delete";
	}

	html += "<table width='100%'>\n";

	html += "<tr>\n";
	html += "	<td style='font-size:20px; color:blue;'>\n";
	html += "			<br>&nbsp;"+msg+" completed. <P>&nbsp;Do you confirm on Production Control &nbsp;Board System screen?</br>";
	html += "	</td>\n";
	html += "</tr>\n";

	html += "</table>\n";

	htmlBtn ="";

	htmlBtn += "<table'>\n";
	htmlBtn += "<tr>\n";
	htmlBtn += "	<td  align = 'left'>　　　　　　";
	htmlBtn += "		<input type='button' id='opBtn' class='btnYes' onclick = 'doSrc2000();'  value='Yes'> <input type='button' id='opBtn' class='btnNo' onclick = 'back();'  value='No'>";
	htmlBtn += "	</td>";

	htmlBtn += "</tr>\n";
	htmlBtn += "</table>\n";


	document.getElementById("opBoard").innerHTML = html;
	document.getElementById("opBoardBtn").innerHTML = htmlBtn;

	document.getElementById("opBoard").style.display = "inline";
	document.getElementById("opBoardButtom").style.display = "inline";
	document.getElementById("opBoardBtn").style.display = "inline";
	document.getElementById("opBoardTop").style.display = "inline";

	//パップアップ以外は非活性
	document.getElementById("allbackgr").style.display = "inline";
}



//修正・削除完了メッセージ
function updateConfirm(registType){
	//OP情報のHTML作成
	var html = "";
	var htmlBtn = "";
	var msg = "";
	if(registType == "update"){
		msg = "修正内容を登録しますか？";
	}else if(registType == "delete"){
		msg = "表示中のデータを削除しますか？";
	}

	html += "<table width='100%'>\n";

	html += "<tr>\n";
	html += "	<td style='font-size:20px; color:blue;'>\n";
	html += "			<br>　"+msg+"</br>";
	html += "	</td>\n";
	html += "</tr>\n";

	html += "</table>\n";

	htmlBtn ="";

	htmlBtn += "<table'>\n";
	htmlBtn += "<tr>\n";
	htmlBtn += "	<td  align = 'left'>　　　　　　";

	if(registType == "update"){
		htmlBtn += "		<input type='button' id='opBtn' class='btnYes' onclick = 'doUpdate()'  value='はい'> <input type='button' id='opBtn' class='btnNo' onclick = 'back();'  value='いいえ'>";
	}else if(registType == "delete"){
		htmlBtn += "		<input type='button' id='opBtn' class='btnYes' onclick = 'doDelete()'  value='はい'> <input type='button' id='opBtn' class='btnNo' onclick = 'back();'  value='いいえ'>";

	}


	htmlBtn += "	</td>";

	htmlBtn += "</tr>\n";
	htmlBtn += "</table>\n";


	document.getElementById("opBoard").innerHTML = html;
	document.getElementById("opBoardBtn").innerHTML = htmlBtn;

	document.getElementById("opBoard").style.display = "inline";
	document.getElementById("opBoardButtom").style.display = "inline";
	document.getElementById("opBoardBtn").style.display = "inline";
	document.getElementById("opBoardTop").style.display = "inline";

	//パップアップ以外は非活性
	document.getElementById("allbackgr").style.display = "inline";

}

//作業内容②５個以上の選択時メッセージ
function selectMultiChk(){


	//OP情報のHTML作成
	var html = "";
    var htmlBtn = "";

	html += "<table width='100%'>\n";

	html += "<tr>\n";
	html += "	<td style='font-size:20px; color:blue;'>\n";
	html += "			<br>　作業内容②は５個以上の<br>　選択は出来ません。 ";
	html += "	</td>\n";
	html += "</tr>\n";

	html += "</table>\n";

	htmlBtn ="";

	htmlBtn += "<table'>\n";
	htmlBtn += "<tr>\n";
	htmlBtn += "	<td  >　　　　　　";
	htmlBtn += "		<input type='button' id='opBtn' class='opBtn' onclick = 'back();'  value='確 認'>";
	htmlBtn += "	</td>";

	htmlBtn += "</tr>\n";
	htmlBtn += "</table>\n";


	document.getElementById("opBoard").innerHTML = html;
	document.getElementById("opBoardBtn").innerHTML = htmlBtn;

	document.getElementById("opBoard").style.display = "inline";
	document.getElementById("opBoardButtom").style.display = "inline";
	document.getElementById("opBoardBtn").style.display = "inline";
	document.getElementById("opBoardTop").style.display = "inline";

	//パップアップ以外は非活性
	document.getElementById("allbackgr").style.display = "inline";

}

//修正・削除対象データが存在しない場合に表示する警告メッセージウィンドウ
function existsDatatChk(type){


	//OP情報のHTML作成
	var html = "";
    var htmlBtn = "";
	var msg = "";

	if(type == "update"){
		msg = "修正";
	}else if(type == "delete"){
		msg = "削除";
	}

	html += "<table width='100%'>\n";

	html += "<tr>\n";
	html += "	<td style='font-size:20px; color:blue;'>\n";
	html += "			<br>　"+msg+"するデータが設備情報に<br>　存在しません。";
	html += "	</td>\n";
	html += "</tr>\n";

	html += "</table>\n";

	htmlBtn ="";

	htmlBtn += "<table'>\n";
	htmlBtn += "<tr>\n";
	htmlBtn += "	<td  >　　　　　　";
	htmlBtn += "		<input type='button' id='opBtn' class='opBtn' onclick = 'back();'  value='確 認'>";
	htmlBtn += "	</td>";

	htmlBtn += "</tr>\n";
	htmlBtn += "</table>\n";


	document.getElementById("opBoard").innerHTML = html;
	document.getElementById("opBoardBtn").innerHTML = htmlBtn;

	document.getElementById("opBoard").style.display = "inline";
	document.getElementById("opBoardButtom").style.display = "inline";
	document.getElementById("opBoardBtn").style.display = "inline";
	document.getElementById("opBoardTop").style.display = "inline";

	//パップアップ以外は非活性
	document.getElementById("allbackgr").style.display = "inline";
}